#! /usr/bin/env python
# -*- coding: utf-8 -*-

# *************************************************************
#     Filename @  property_cache.py
#       Author @  Huoty
#  Create date @  2016-08-11 18:03:50
#  Description @  
# *************************************************************

from cached_property import cached_property

class Foo(object):
    def __init__(self, x):
        self.x = x

        self.__dict__["tar"] = "descriptor test"

    @property
    def tar(self):
        print "running tar"
        return self.x

    @cached_property
    def far(self):
        print "running tar"
        return self.x

# Script starts from here

if __name__ == "__main__":
    f = Foo(5)
    print f.tar
    print f.far

    print f.tar
    print f.far

    print getattr(f, "x")

